
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/commonly-used-show.css" />
    <script type="text/javascript" src="approvalProcess/js/jquery.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap.js" ></script>
    <script type="text/javascript" src="approvalProcess/js/jquery.cookie.js"></script>

    <!--  分页显示 -->
    <script src="approvalProcess/js/jqPaginator.min.js" type="text/javascript"></script>
    <link href="approvalProcess/css/myPage.css" rel="stylesheet" type="text/css" />
    <script src="approvalProcess/js/myPage.js" type="text/javascript"></script>


     <title>查看审批</title>


</head>
<body class="mybody">


 <jsp:include page="theTopMenuDoorkeeper.jsp" />


<div class="container-fluid">
    <div class="row">

        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">

                            <div >
                                <h3 style="text-align: center">查看审批</h3>

                                <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />


                                <div id="modality">

                                </div>


                                 <div class="text-center">

                                     <div style="float: left; margin-left: 130px;" class="col-lg-4 ">
                <div class="input-group">
                    <input id="user_find" type="text" class="form-control" placeholder="账号或姓名查找">
                    <span class="input-group-btn">
                        <button class="btn btn-default" type="button" onclick="findUse()">查找</button>
                    </span>
                </div>
            </div>

                                         <div style="clear: both">

                                    </div>

                                     <div style="margin-top: 20px;">
                                    <span id="user_messge" style="font-size:18px; color: red;"></span>
                                </div>

                                <div>
                                    <ul class="pagination" id="pagination"></ul>
                                    <!--PageCount是一共多少条数据-->
                                    <input type="hidden" id="PageCount" />
                                    <!--PageSize是页面显示多少条数据-->
                                    <input type="hidden" id="PageSize" value="6"/>
                                    <!--countindex这个参数是通过上面的PageCount与PageSize计算出来的分多少页-->
                                    <!--js中是自动计算的，可默认也可以自己填-->
                                    <input type="hidden" id="countindex" value="10"/>
                                    <!--上一页与下一页中间的数字框，要显示几个就value多少个-->
                                    <input type="hidden" id="visiblePages" value="7"/>
                                </div>

                                 </div>


                            </div>

                        </div>
                    </div>
                </div>
        </div>

    </div>

 </div>










<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }


    //设置全局变量
    var numes = 1;
    var isok = true;

    /*loadData(num,count)写在$(function(){})外，num为当前选中页码，count是我自己加的，是ajax返回的数据总数*/
    function loadData(num, count) {
        numes = num;
        if (count){
            $("#PageCount").val(count);
        }else {
            $("#PageCount").val("5");
        }

        //当点击首页，下一页，上一页，尾页，数字页码时执行ajax数据操作
        if (numes !== 1){
            queryApplicationInfo();
        }else if (numes === 1){
            queryApplicationInfo();
        }

    }

    //输入查找的条件时进行查找操作
    function findUse(){
        isok = true;
        queryApplicationInfo();
    }

    //每当数据发生变动时进行页面的刷新
    function uppag(count){
        //重新加载分页控件
        loadData(1, count);
        loadpage();
        isok = false;
    }

    window.onload = function(){
        queryApplicationInfo();
    }

    function queryApplicationInfo(){
        var postUrl = "${pageContext.request.contextPath}/shareQueryApplication";
        var str = {
            "pageResult": {
                "currentPage": numes,
                "pageSize": 6
            },
            "myApproval": {
                "userLevel" : userdt.result.userLevel,
                "approvalNoteId" : userdt.result.id,
                "approvalStatus": "${param.type}"
            },
            "accessStatus": "${param.type}",
            "teacherStudentNumber": $("#user_find").val(),
            "userName": $("#user_find").val()
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){

                    $("#user_messge").text(data.msg);

                    if (data.msg === "查询失败,无该数据"){
                        uppag(0);
                        $("#modality").html("");
                    }
                }else {
                    //全局变量，第一次加载后就不执行了，当用户进行查找操作时在继续执行
                    if (isok){
                        uppag(data.result.totalSize);
                    }


                    stocks(data);


                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });
    }


    //已完成
    function stocks(data){
        var strtab = "";
        //清空表格数据
        $("#modality").html("");

        var userType = "";
        var staffType = "";
        var userTel = "";

        for (var i = 0; i < data.result.items.length; i++) {

            if (data.result.items[i].counsellorId != null){
                userType = "doorkeeperCheckACA?id=";
                staffType = "<b style='float: right; margin-right: 50px'><span>年级：</span> <span>" + data.result.items[i].userReplenish.belongsGrade + "</span></b>";
                userTel = "<b style='float: left; margin-left: 50px'><span>专业班级：</span> <span>" + data.result.items[i].userReplenish.belongsClass + "</span></b>";
            }else {
                userType = "doorkeeperCheckTeacherACA?id=";
                staffType = "<b style='float: right; margin-right: 50px;'><span>人员类型：</span> <span>" + "教师" + "</span></b>";
                userTel = "<b style='float: left; margin-left: 50px'><span>联系电话：</span> <span>" + data.result.items[i].contactNumber + "</span></b>";
            }

            strtab = "<div style='margin-left: 130px; margin-right: 130px' class='panel panel-primary'>" +
            "<a href='${pageContext.request.contextPath}/" + userType + data.result.items[i].id + "&type=${param.type}'>" +
                "<div class='panel-body'>" +
                "<div style='height: 180px;' class='alert alert-success'>" +
                "<div style='clear: both; padding: 10px;'>" +
                "<b style='float: left; margin-left: 50px'><span>学院：</span> <span>" + data.result.items[i].userReplenish.belongsCollege + "</span></b>" +
                staffType +
        "</div>" +
        "<div style='clear: both; padding: 10px;'>" +
                userTel +
        "<b style='float: right; margin-right: 50px'><span>姓名：</span> <span>" + data.result.items[i].userName + "</span></b>" +
        "</div>" +
        "<div style='clear: both; padding: 10px;'>" +
        "<b style='float: left; margin-left: 50px'><span>出校时间：</span> <span>" + data.result.items[i].startTime + "</span></b>" +
        "<b style='float: right; margin-right: 50px'><span style='font-size: 20px'>院领导审核状态：</span> <span style='font-size: 20px'>" + "审核通过" + "</span></b>" +
        "</div>" +
        "<div style='clear: both; padding: 10px;'>" +
        "<b style='float: left; margin-left: 50px'><span>返校时间：</span> <span>" + data.result.items[i].endTime + "</span></b>" +
        "<b style='float: right; margin-right: 50px'><span style='font-size: 20px'>校领导审核状态：</span> <span style='font-size: 20px'>" + "审核通过" + "</span></b>" +
        "</div>" +
        "</div>" +
        "</div>" +
        "</a>" +
        "</div>";

            $("#modality").append(strtab);//将数据追加进表格
        }
    }


</script>

</body>
</html>
</span>